using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using WHC.Hotel.Entity;
using WHC.Hotel.IDAL;
using WHC.OrderWater.Commons;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// InitConsumer 的摘要说明。
	/// </summary>
	public class InitConsumer : BaseDAL<InitConsumerInfo>, IInitConsumer
	{
		#region 对象实例及构造函数

		public static InitConsumer Instance
		{
			get
			{
				return new InitConsumer();
			}
		}
		public InitConsumer() : base("KF_InitConsumer","ID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override InitConsumerInfo DataReaderToEntity(IDataReader dataReader)
		{
			InitConsumerInfo initConsumerInfo = new InitConsumerInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			initConsumerInfo.ID = reader.GetInt32("ID");
			initConsumerInfo.RoomType = reader.GetString("RoomType");
            initConsumerInfo.ItemType = reader.GetString("ItemType");
            initConsumerInfo.ItemNo = reader.GetString("ItemNo");
			initConsumerInfo.ItemName = reader.GetString("ItemName");
			initConsumerInfo.Price = reader.GetDecimal("Price");
			initConsumerInfo.Discount = reader.GetDouble("Discount");
			initConsumerInfo.DiscountPrice = reader.GetDecimal("DiscountPrice");
			initConsumerInfo.Quantity = reader.GetDouble("Quantity");
			initConsumerInfo.Amount = reader.GetDecimal("Amount");
			initConsumerInfo.Note = reader.GetString("Note");
			
			return initConsumerInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(InitConsumerInfo obj)
		{
		    InitConsumerInfo info = obj as InitConsumerInfo;
			Hashtable hash = new Hashtable(); 
			
 			hash.Add("RoomType", info.RoomType);
            hash.Add("ItemType", info.ItemType);
 			hash.Add("ItemName", info.ItemName);
            hash.Add("ItemNo", info.ItemNo);
 			hash.Add("Price", info.Price);
 			hash.Add("Discount", info.Discount);
 			hash.Add("DiscountPrice", info.DiscountPrice);
 			hash.Add("Quantity", info.Quantity);
 			hash.Add("Amount", info.Amount);
 			hash.Add("Note", info.Note);
 				
			return hash;
		}

    }
}